﻿
using System.Collections.Generic;
using System.Linq;
using Tau.DataAccess;

namespace Tau.Service.Adapters
{
    internal class Category : IAdapter<Model.Category, tblCategory>
    {
        public Model.Category GetModelObject(tblCategory dbObject)
        {
            var model = new Model.Category()
                                  {
                                      CategoryId = dbObject.categoryID,
                                      CategoryName = dbObject.category
                                  };
            return model;
        }

        public tblCategory GetDbObject(Model.Category model)
        {
            var dbObject = new tblCategory()
                           {
                               category = model.CategoryName,
                               categoryID = model.CategoryId
                           };
            return dbObject;
        }

        public List<Model.Category> GetModelList(List<tblCategory> dbObjectList)
        {
            return dbObjectList.Select(dbCategory => GetModelObject(dbCategory)).ToList();
        }
    }
}
